// -*-C++-*-
#ifndef __ISOCKET_H__
# define __ISOCKET_H__

#include <iostream>

class ISocket
{
public:
    // type = SOCK_STREAM | SOCK_DGRAM
    // domain = AF_INET | AF_INET6
    virtual void open(int domain, int type) = 0;

    // server-side
    virtual void bind(int port, char *addr) = 0;
    virtual void listen(int backlog) = 0;
    virtual void accept(ISocket *) = 0;

    // client-side
    virtual void connect(int port, char *addr) = 0;

    // socket stream
    virtual int send(const void *msg, size_t len) = 0;
    virtual int recv(void *buf, size_t len) = 0;

    virtual void close() = 0;
};

#endif /* __ISOCKET_H__ */
